arrays = [
    [9, 5, 3, 1, 2, 4, 6, 8, 7],
    [78, 56, 69, 22, 90, 66, 32, 56, 11, 29, 75, 33, 39, 65, 48, 61, 99, 84, 59, 17],
]


def merge_two_array(a, b):
    c = []
    i = 0
    j = 0
    while i < len(a) and j < len(b):
        if a[i] < b[j]:
            c.append(a[i])
            i += 1
        else:
            c.append(b[j])
            j += 1

    while i < len(a):
        c.append(a[i])
        i += 1
    while j < len(b):
        c.append(b[j])
        j += 1

    return c

def merge_sort(num):
    if len(num) <= 1:
        return num

    mid = len(num) // 2
    left = merge_sort(num[:mid])
    right = merge_sort(num[mid:])
    return merge_two_array(left, right)

    return array

for array in arrays:
    print("排序结果:",merge_sort(array))
